// var o;
// exports.DateData = void 0;
// var $storageClass = require("../../resources/scripts/AL_Framework_Storage_Class");
// var AL_GAME_HUA_Common = require("./AL_GAME_HUA_Common");
// var AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
// var AL_GAME_HUA_GameData = require("./AL_GAME_HUA_GameData");
// var AL_GAME_HUA_MissionData = require("./AL_GAME_HUA_MissionData");
// var AL_GAME_HUA_OnlineGiftData = require("./AL_GAME_HUA_OnlineGiftData");
// var AL_GAME_HUA_PayData = require("./AL_GAME_HUA_PayData");
// var AL_GAME_HUA_WelfareData = require("./AL_GAME_HUA_WelfareData");
// var d = {
//     dateSign: -1,
//     weekSign: -1
// };
// var h = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.nowDate = null;
//         return t;
//     }
//     __extends(t, e);
//     t.getInstance = function () {
//         return AL_APP_SDK_MANAGER.localManager.huoqu_cunchu_lei(t);
//     };
//     t.prototype.zhixing_chushihua_chuli = function () {
//         this.chushihua_cunchu_shuju(d);
//         this.chushihua_yuancheng_key(Object.keys(d));
//     };
//     t.prototype.jiancha_riqi_he_zhou_shifou_xuyao_shuaxin = function () {
//         var e = this.huoqu_dangqian_shijian();
//         if (!(-1 != this.dateSign && 0 == AL_APP_SDK_MANAGER.utils.huoqu_riqi_jian_de_tianshu_cha(this.dateSign, e))) {
//             this.shuaxin_riqi_xianguan_shuju();
//             this.dateSign = e;
//         }
//         if (-1 == this.weekSign || Math.abs(AL_APP_SDK_MANAGER.utils.huoqu_riqi_jian_de_tianshu_cha(this.weekSign, e)) > 7) {
//             this.shuaxin_zhou_xianguan_shuju();
//             this.weekSign = this.huoqu_dangqian_zhouyi_de_riqi();
//         }
//     };
//     t.prototype.huoqu_dangqian_zhouyi_de_riqi = function () {
//         var e = this.huoqu_dangqian_shijian();
//         var t = 0 == new Date().getDay() ? 7 : new Date().getDay();
//         return new Date(e - 864e5 * (t - 1)).getTime();
//     };
//     t.prototype.shuaxin_riqi_xianguan_shuju = function () {
//         AL_GAME_HUA_MissionData.MissionData.getInstance().shuaxin_riqi_xianguan_shuju();
//         AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().shuaxin_riqi_xianguan_shuju();
//         AL_GAME_HUA_GameData.GameData.getInstance().shuaxin_riqi_xianguan_shuju();
//         AL_GAME_HUA_PayData.PayData.getInstance().shuaxin_riqi_xianguan_shuju();
//         AL_GAME_HUA_WelfareData.WelfareData.getInstance().shuaxin_riqi_xianguan_shuju();
//     };
//     t.prototype.shuaxin_zhou_xianguan_shuju = function () {
//         AL_GAME_HUA_MissionData.MissionData.getInstance().shuaxin_zhou_xianguan_shuju();
//     };
//     t.prototype.huoqu_dangqian_shijian = function () {
//         return this.nowDate ? this.nowDate : AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
//     };
//     t.bundle = AL_GAME_HUA_Define.Define.GAME_NAME;
//     t.key = "_g";
//     return t;
// })($storageClass.AL_Framework_Storage_Class);
// exports.DateData = h;


/**
 * DateData类用于管理日期相关的存储和操作。
 * 继承自StorageClass。
 */
// var localStorageInstance;
// exports.DateData = void 0;
// var storageClass = require("../../resources/scripts/AL_Framework_Storage_Class");
// var AL_GAME_HUA_Common = require("./AL_GAME_HUA_Common");
// var AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
// var AL_GAME_HUA_GameData = require("./AL_GAME_HUA_GameData");
// var AL_GAME_HUA_MissionData = require("./AL_GAME_HUA_MissionData");
// var AL_GAME_HUA_OnlineGiftData = require("./AL_GAME_HUA_OnlineGiftData");
// var AL_GAME_HUA_PayData = require("./AL_GAME_HUA_PayData");
// var AL_GAME_HUA_WelfareData = require("./AL_GAME_HUA_WelfareData");

// var defaultStorageData = {
//     dateSign: -1,
//     weekSign: -1
// };

// /**
//  * DateData类的构造函数
//  * @constructor
//  */
// var DateDataClass = (function (baseClass) {
//     function DateData() {
//         var instance = (null !== baseClass && baseClass.apply(this, arguments)) || this;
//         instance.nowDate = null; // 当前日期为null， 可以使用getNow()获取实际值
//         return instance;
//     }
//     __extends(DateData, baseClass);

//     /**
//      * 获取DateData的单例
//      * @returns {DateData} 返回单例实例
//      */
//     DateData.getInstance = function () {
//         return AL_APP_SDK_MANAGER.localManager.huoqu_cunchu_lei(DateData);
//     };

//     /**
//      * 初始化DateData对象
//      */
//     DateData.prototype.zhixing_chushihua_chuli = function () {
//         this.chushihua_cunchu_shuju(defaultStorageData);
//         this.chushihua_yuancheng_key(Object.keys(defaultStorageData));
//     };

//     /**
//      * 检查日期和周是否需要刷新，并执行相关操作
//      */
//     DateData.prototype.jiancha_riqi_he_zhou_shifou_xuyao_shuaxin = function () {
//         var currentDate = this.huoqu_dangqian_shijian();
//         if (!(-1 != this.dateSign && 0 == AL_APP_SDK_MANAGER.utils.huoqu_riqi_jian_de_tianshu_cha(this.dateSign, currentDate))) {
//             this.shuaxin_riqi_xianguan_shuju();
//             this.dateSign = currentDate;
//         }
//         if (-1 == this.weekSign || Math.abs(AL_APP_SDK_MANAGER.utils.huoqu_riqi_jian_de_tianshu_cha(this.weekSign, currentDate)) > 7) {
//             this.shuaxin_zhou_xianguan_shuju();
//             this.weekSign = this.huoqu_dangqian_zhouyi_de_riqi();
//         }
//     };

//     /**
//      * 获取当前周一的日期
//      * @returns {number} 返回当前周一的时间戳
//      */
//     DateData.prototype.huoqu_dangqian_zhouyi_de_riqi = function () {
//         var currentDate = this.huoqu_dangqian_shijian();
//         var dayOfWeek = new Date().getDay() === 0 ? 7 : new Date().getDay();
//         return new Date(currentDate - 86400000 * (dayOfWeek - 1)).getTime();
//     };

//     /**
//      * 刷新日期相关的数据
//      */
//     DateData.prototype.shuaxin_riqi_xianguan_shuju = function () {
//         AL_GAME_HUA_MissionData.MissionData.getInstance().shuaxin_riqi_xianguan_shuju();
//         AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().shuaxin_riqi_xianguan_shuju();
//         AL_GAME_HUA_GameData.GameData.getInstance().shuaxin_riqi_xianguan_shuju();
//         AL_GAME_HUA_PayData.PayData.getInstance().shuaxin_riqi_xianguan_shuju();
//         AL_GAME_HUA_WelfareData.WelfareData.getInstance().shuaxin_riqi_xianguan_shuju();
//     };

//     /**
//      * 刷新周相关的数据
//      */
//     DateData.prototype.shuaxin_zhou_xianguan_shuju = function () {
//         AL_GAME_HUA_MissionData.MissionData.getInstance().shuaxin_zhou_xianguan_shuju();
//     };

//     /**
//      * 获取当前日期
//      * 如果nowDate为null则调用AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian()
//      * @returns {number} 返回当前日期
//      */
//     DateData.prototype.huoqu_dangqian_shijian = function () {
//         return this.nowDate ? this.nowDate : AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
//     };

//     // DateData类的常量标识符
//     DateData.bundle = AL_GAME_HUA_Define.Define.GAME_NAME;
//     DateData.key = "_g";

//     return DateData;
// })(storageClass.AL_Framework_Storage_Class);

// exports.DateData = DateDataClass;


let localStorageInstance;
exports.DateData = void 0;

const storageClass = require("../../resources/scripts/AL_Framework_Storage_Class");
const AL_GAME_HUA_Common = require("./AL_GAME_HUA_Common");
const AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
const AL_GAME_HUA_GameData = require("./AL_GAME_HUA_GameData");
const AL_GAME_HUA_MissionData = require("./AL_GAME_HUA_MissionData");
const AL_GAME_HUA_OnlineGiftData = require("./AL_GAME_HUA_OnlineGiftData");
const AL_GAME_HUA_PayData = require("./AL_GAME_HUA_PayData");
const AL_GAME_HUA_WelfareData = require("./AL_GAME_HUA_WelfareData");

const defaultStorageData = {
    dateSign: -1,
    weekSign: -1,
};

/**
 * DateData类，用于管理日期和周相关的数据
 */
class DateDataClass extends storageClass.AL_Framework_Storage_Class {
    constructor() {
        super();
        /**
         * 当前日期，为null时可通过get_now()方法获取实际值
         * @type {number|null}
         */
        this.nowDate = null;
    }

    /**
     * 获取DateData的单例
     * @returns {DateDataClass} 返回单例实例
     */
    static getInstance() {
        return AL_APP_SDK_MANAGER.localManager.huoqu_cunchu_lei(DateDataClass);
    }

    /**
     * 初始化DateData对象
     */
    zhixing_chushihua_chuli() {
        this.chushihua_cunchu_shuju(defaultStorageData);
        this.chushihua_yuancheng_key(Object.keys(defaultStorageData));
    }

    /**
     * 检查日期和周是否需要刷新，并执行相关操作
     */
    jiancha_riqi_he_zhou_shifou_xuyao_shuaxin() {
        const currentDate = this.huoqu_dangqian_shijian();
        const dateDiff = AL_APP_SDK_MANAGER.utils.huoqu_riqi_jian_de_tianshu_cha(this.dateSign, currentDate);

        if (this.dateSign === -1 || dateDiff !== 0) {
            this.shuaxin_riqi_xianguan_shuju();
            this.dateSign = currentDate;
        }

        const weekDiff = Math.abs(AL_APP_SDK_MANAGER.utils.huoqu_riqi_jian_de_tianshu_cha(this.weekSign, currentDate));
        if (this.weekSign === -1 || weekDiff > 7) {
            this.shuaxin_zhou_xianguan_shuju();
            this.weekSign = this.huoqu_dangqian_zhouyi_de_riqi();
        }
    }

    /**
     * 获取当前周一的日期
     * @returns {number} 返回当前周一的时间戳
     */
    huoqu_dangqian_zhouyi_de_riqi() {
        const currentDate = this.huoqu_dangqian_shijian();
        const currentDayOfWeek = new Date().getDay() || 7; // 如果为周日（getDay()返回0），则设为7
        const millisecondsInADay = 86400000; // 一天的毫秒数
        return new Date(currentDate - millisecondsInADay * (currentDayOfWeek - 1)).getTime();
    }

    /**
     * 刷新日期相关的数据
     */
    shuaxin_riqi_xianguan_shuju() {
        AL_GAME_HUA_MissionData.MissionData.getInstance().shuaxin_riqi_xianguan_shuju();
        AL_GAME_HUA_OnlineGiftData.OnlineGiftData.getInstance().shuaxin_riqi_xianguan_shuju();
        AL_GAME_HUA_GameData.GameData.getInstance().shuaxin_riqi_xianguan_shuju();
        AL_GAME_HUA_PayData.PayData.getInstance().shuaxin_riqi_xianguan_shuju();
        AL_GAME_HUA_WelfareData.WelfareData.getInstance().shuaxin_riqi_xianguan_shuju();
    }

    /**
     * 刷新周相关的数据
     */
    shuaxin_zhou_xianguan_shuju() {
        AL_GAME_HUA_MissionData.MissionData.getInstance().shuaxin_zhou_xianguan_shuju();
    }

    /**
     * 获取当前日期
     * 如果nowDate为null，则调用AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian()
     * @returns {number} 返回当前日期
     */
    huoqu_dangqian_shijian() {
        return this.nowDate || AL_GAME_HUA_Common.Common.huoqu_dangqian_shijian();
    }
}

// DateData类的常量标识符
DateDataClass.bundle = AL_GAME_HUA_Define.Define.GAME_NAME;
DateDataClass.key = "_g";

exports.DateData = DateDataClass;
